package com.hatricks.is.ai;

import java.util.Random;
import java.util.concurrent.ThreadLocalRandom;

/**
 * @packageName: com.hatricks.is.ai
 * @className: AugmentEmailGeneratorUtils
 * @author: yanyuhui y568821795@outlook.com
 * @date: 2025-07-15 09:47
 * @description:
 */
public class AugmentEmailGeneratorUtils {

    // 常见邮箱域名 腾讯云已购买域名
    private static final String[] DOMAINS = {"aihs.chat"};

    // 常用用户名前缀
    private static final String[] USER_PREFIXES = {
            "john", "sarah", "mike", "lisa", "david", "emma", "chris", "anna",
            "alex", "james", "laura", "robert", "sophie", "daniel", "olivia"
    };

    // 常用用户名后缀
    private static final String[] USER_SUFFIXES = {
            "smith", "johnson", "williams", "brown", "jones", "miller", "davis",
            "garcia", "rodriguez", "wilson", "martinez", "anderson", "thomas"
    };

    // 数字分隔符
    private static final String[] NUMBER_SEPARATORS = {"", ".", "_", "-"};

    public static void main(String[] args) {
        System.out.println("随机邮箱地址: " + generateRandomEmail());
        System.out.println("随机邮箱地址: " + generateRandomEmail());
        System.out.println("随机邮箱地址: " + generateRandomEmail());
    }

    public static String generateRandomEmail() {
        Random random = ThreadLocalRandom.current();
        // 生成用户名部分（3种常见格式）
        String username;
        int usernameType = random.nextInt(3);
        switch (usernameType) {
            case 0: // 前缀+后缀格式 (e.g., john.smith)
                username = USER_PREFIXES[random.nextInt(USER_PREFIXES.length)] + NUMBER_SEPARATORS[random.nextInt(NUMBER_SEPARATORS.length)] + USER_SUFFIXES[random.nextInt(USER_SUFFIXES.length)];
                break;
            case 1: // 前缀+数字格式 (e.g., david1987)
                username = USER_PREFIXES[random.nextInt(USER_PREFIXES.length)] + random.nextInt(10000);
                break;
            default: // 随机字母组合 (e.g., zk82n)
                int length = 5 + random.nextInt(6); // 5-10个字符
                StringBuilder sb = new StringBuilder();
                for (int i = 0; i < length; i++) {
                    // 混合使用小写字母和数字
                    if (random.nextBoolean()) {
                        sb.append((char) ('a' + random.nextInt(26)));
                    } else {
                        sb.append(random.nextInt(10));
                    }
                }
                username = sb.toString();
        }
        // 随机选择域名
        String domain = DOMAINS[random.nextInt(DOMAINS.length)];
        return username + "@" + domain;
    }
}
